home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 1994 August / August CD.bin / Shareware / Education / numericalmethods Folder / chap_7 / srule.m < prev    next >
Encoding:
Text File  |  1994-06-05  |  279 b   |  18 lines  |  [MATF/MATL]

  1. function Z = srule(f,a0,b0,tol0)
  2. % Z = srule(f,a0,b0,tol0)
  3. % Subroutine for adaptive quadrature.
  4. h  = (b0 - a0)/2;
  5. c0 = (a0 + b0)/2;
  6. Fa = feval(f,a0);
  7. Fc = feval(f,c0);
  8. Fb = feval(f,b0);
  9. S  = h*(Fa + 4*Fc + Fb)/3;
  10. S2 = S;
  11. tol1 = tol0;
  12. err  = tol0;
  13. Z = [a0 b0 S S2 err tol1];
  14.  
  15.  
  16.  
  17.  
  18.